package me.pinion;


public class Log {
    public static String I_PREFIX = "[ INFO ] -> ";
    public static String W_PREFIX = "[ WARN ] -> ";
    public static String D_PREFIX = "[ DEBUG ] -> ";
    public static String E_PREFIX = "[ ERROR ] -> ";
    public static boolean DEBUG = true;
    private static void o(Object o){
        if (DEBUG)
            print(o);
    }

    private static void or(Object o){
        if (DEBUG)
            println(o);
    }

    /**
     * Level info
     * @param os
     */
    public static void i(Object... os){
        o(I_PREFIX);
        os.each {
            o(it)
        }
        or("");
    }

    /**
     * Level warn
     * @param os
     */
    public static void w(Object... os){
        o(W_PREFIX);
        os.each {
            o(it)
        }
        or("");
    }

    /**
     * Level debug
     * @param os
     */
    public static void d(Object... os){
        o(D_PREFIX);
        os.each {
            o(it)
        }
        or("");
    }

    /**
     * Level err
     * @param e
     */
    public static void e(Exception e){
        o(E_PREFIX);
        o(e.getMessage());
        or("");
        or("{ line } => " + e.getStackTrace()[2].getLineNumber());
        or("{ class } => " + e.getStackTrace()[2].getClassName());
        or("{ method } => " + e.getStackTrace()[2].getMethodName());
    }
}
